def nugget_sort(leftRec, rightRec):
    res=[]
    while len(leftRec)>0 and len(rightRec)>0:
        if leftRec[0]<=rightRec[0]:
            res.append(leftRec.pop(0))
        else:
            res.append(rightRec.pop(0))
    res+=leftRec
    res+=rightRec
    return res

def goldNugget(lt):
    if len(lt)==1:
        return lt
    # 分解
    mid = len(lt) // 2
    left=lt[:mid]
    right=lt[mid:]

    # 解题
    leftRec=goldNugget(left)
    rightRec=goldNugget(right)
    return nugget_sort(leftRec,rightRec)

n=int(input())
lt=[]
for i in range(n):
    num=int(input())
    lt.append(num)
res=goldNugget(lt)
print(res[len(res)-1],res[0])



